﻿using System;
using System.Collections.Generic;
using System.Runtime.Serialization;

namespace CapstoneProjectAEReader.Entities.Models
{
    [Serializable()]
    public class SettingDetail
    {
        #region Atttributes

        public int FontSize { get; set; }

        public string SelectedFontType { get; set; }

        public string ApplicationLanguage { get; set; }

        public int ReadingMode { get; set; }

        private List<Ebook> _recentRead = new List<Ebook>();

        public int MaxEbookId { get; set; }
        public int MaxEbookGroupId { get; set; }
        public int MaxNoteId { get; set; }

        public List<Ebook> RecentRead
        {
            get { return _recentRead; }
            set { _recentRead = value; }
        }

        #endregion

        // Serialize

        public SettingDetail(){}

        public SettingDetail(SerializationInfo info, StreamingContext ctxt)
        {
            FontSize = (int)info.GetValue("FontSize", typeof(int));
            SelectedFontType = (string)info.GetValue("SelectedFontType", typeof(string));
            ApplicationLanguage = (string)info.GetValue("ApplicationLanguage", typeof(string));
            ReadingMode = (int)info.GetValue("ReadingMode", typeof(int));
            RecentRead = (List<Ebook>) info.GetValue("RecentRead", typeof (List<Ebook>));
        }

        public void GetObjectData(SerializationInfo info, StreamingContext ctxt)
        {
            info.AddValue("FontSize", FontSize);
            info.AddValue("SelectedFontType", SelectedFontType);
            info.AddValue("ApplicationLanguage", ApplicationLanguage);
            info.AddValue("ReadingMode", ReadingMode);
            info.AddValue("RecentRead", RecentRead);
        }
        
    }
}
